﻿<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<c:set var="baseUri" value="${pageContext.request.contextPath }"
       scope="request"></c:set>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>图书管理系统</title>
    <link rel="stylesheet" href="${baseUri}/static/layui/css/layui.css">
</head>
<style>
    <!--
    * {
        margin: 0;
        padding: 0;
    }

    .searchBar {
        height: 100px;
        background-color: #99cc33;
    }

    .hBar {
        height: 50px;
        line-height: 50px;
        position: relative;
        top: 25px;
        left: 100px;
    }
    label, input, button {
        font-size: 25px;
        font-family: "楷体";
    }
    -->
</style>
<body>
<!-- 内容主体区域 -->
<fieldset class="layui-elem-field layui-field-title"
          style="margin-top: 20px;">
    <legend>查询图书</legend>
</fieldset>


<!-- 模糊查询字段-->
<div class="searchBar" style="background-color: #f3f3f3">
    <div class="hBar">
        <form action="searchBookPage" method="get">
            <label class="">图书标题</label>
            <input type="text" name="title" class="" style="width: 200px;" placeholder="${placeholder1 }">
            <label class="">作者</label>
            <input type="text" name="author" class="" style="width: 200px;" placeholder="${placeholder2 }">
            <button id="sub_but" type="submit" class="">搜索</button>
        </form>
    </div>
</div>

<div class="layui-form">
    <table class="layui-table">
        <colgroup>
            <col width="150">
            <col width="130">
            <col width="100">
            <col width="70">
            <col width="100">
            <col width="350">
            <col width="120">
            <col width="120">
            <col width="120">
            <col width="100">
            <col width="100">
        </colgroup>
        <thead>
        <tr>
            <th style="text-align: center">ISBN</th>
            <th style="text-align: center">书名</th>
            <th style="text-align: center">作者</th>
            <th style="text-align: center">类型</th>
            <th style="text-align: center">价格(元)</th>
            <th style="text-align: center">简介</th>
            <th style="text-align: center">数量(剩/总)</th>
            <th style="text-align: center">查看</th>
            <th style="text-align: center">借阅/预约</th>
            <c:if test="${msAdmin.identityId==0 }"> <!-- 管理员身份 -->
                <th style="text-align: center">编辑</th>
                <th style="text-align: center">下架</th>
            </c:if>
        </tr>
        </thead>
        <tbody>
        <c:forEach items="${requestScope.pageMsg.lists}" var="book">
            <tr>
                <td>${book.isbn }</td>
                <td>${book.title }</td>
                <td>${book.author }</td>
                <td>${book.categoryId }</td>
                <td>${book.price }</td>
                <td>${book.introduction }</td>
                <td>${book.remainder }/${book.sum }</td>
                <td><a class="layui-btn"
                       style="background-color: cadetblue" href="bookDetail?id=${book.id }">查看</a></td>
                <td>
                    <c:if test="${book.remainder == 0 }">
                        <a class="layui-btn"
                           style="background-color: rgb(204, 139, 41)"
                           href="booking?id=${book.id }&from=searchBook">预约</a>
                    </c:if>
                    <c:if test="${book.remainder > 0 }">
                        <a class="layui-btn"
                           style="background-color: rgb(204, 139, 41)"
                           href="toBorrowBook?id=${book.id }&from=searchBook">借阅</a>
                    </c:if>
                </td>
                <c:if test="${msAdmin.identityId==0 }"> <!-- 管理员身份 -->
                    <td><a class="layui-btn"
                           style="background-color: rgb(204, 139, 41)" href="toUpdateBook?id=${book.id }">编辑</a></td>
                    <td><a class="layui-btn"
                           style="background-color: rgb(211, 26, 81)" href="deleteSearchBook?id=${book.id }">下架</a></td>
                </c:if>
            </tr>
        </c:forEach>
        </tbody>
    </table>
</div>

<script src="${baseUri}/static/layui/layui.js"></script>
<script>
    // alert(document.getElementsByTagName("td").length);
    if (document.getElementsByTagName("td").length==0) {
        document.getElementById("sub_but").click();
    }
    //JavaScript代码区域
    layui.use('element', function () {
        var element = layui.element;

    });
    layui.use(['form'], function () {
        var form = layui.form;
    });
    layui.use('carousel', function () {
        var carousel = layui.carousel;
        //建造实例
        carousel.render({
            elem: '#test1',
            width: '100%' //设置容器宽度
            ,
            arrow: 'always' //始终显示箭头
            //,anim: 'updown' //切换动画方式
        });
    });
</script>
</body>
</html>